package dao.impl;

import dao.BaseDao;
import dao.StudentDao;
import entity.JavaBean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Studentimpl implements StudentDao {
    @Override
    public List<JavaBean> getAllStudent() throws SQLException {
        String sql="SELECT * FROM studentInfo";
        BaseDao dao = new BaseDao();
        ResultSet resultSet = dao.ExecuteQuery(sql);
         int sid=0;
        String sname=null;
        String sgender=null;
       int sage=0;
         String saddress=null;
       String semail=null;
        JavaBean javaBean = null;
        ArrayList<JavaBean> list = new ArrayList<>();
        while (resultSet.next()){
          sid = resultSet.getInt("sid");
          sname = resultSet.getString("sname");
          sgender = resultSet.getString("sgender");
          sage = resultSet.getInt("sage");
          saddress = resultSet.getString("saddress");
          semail = resultSet.getString("semail");
            javaBean=new JavaBean(sid,sname,sgender,sage,saddress,semail);
            list.add(javaBean);
     }
        return list;
    }
}
